package org.spiderflow.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.spiderflow.common.controller.CURDController;
import org.spiderflow.core.mapper.VariableMapper;
import org.spiderflow.core.model.Variable;
import org.spiderflow.core.service.VariableService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zsh
 */
@RestController
@RequestMapping("/spider/variable")
public class VariableController extends CURDController<VariableService, VariableMapper, Variable> {
    public VariableController(VariableService service) {
        super(service);
    }

    @RequestMapping("/list")
    public IPage<Variable> list(@RequestParam(name = "page", defaultValue = "1") Integer page,
                                @RequestParam(name = "limit", defaultValue = "1") Integer size) {
        return service.page(new Page<>(page, size), new QueryWrapper<Variable>().orderByDesc("create_date"));
    }
}
